function initRoles() {
    $.ajax({
        type: 'get',
        url: '/sysRole/all',
        async: false,
        success: function (data) {
            var r = $("#roles");

            for (var i = 0; i < data.length; i++) {
                var d = data[i];
                var id = d['id'];
                var name = d['name'];

                var t = "<label><input  type='radio' value='" + id + "' name='roleId'>"
                    + name + "</label> &nbsp&nbsp";

                r.append(t);
            }
        }
    });
}

function getCheckedRoleIds() {
    var ids = null;
    var val=$('input:radio[name="roleId"]:checked').val();
    $("#roles input[type='radio']")
    if (val) {
        ids = val;
    }
    console.log(ids)
    return ids;
}

function initRoleDatas(userId) {
    $.ajax({
        type: 'get',
        url: '/sysRole/userId?userId=' + userId,
        success: function (data) {
            var length = data.length;
            for (var i = 0; i < length; i++) {
                $("input[type='radio']").each(function () {
                    var v = $(this).val();
                    if (v == data[i]['id']) {
                        $(this).attr("checked", true);
                    }
                });
            }
        }
    });
}